﻿#include "WRWorkDomainChangeEvent.h"

static int g_workDomainChangeEventType = QEvent::registerEventType();

//判断指定的事件是否是当前事件。
bool WRWorkDomainChangeEvent::identify(const QEvent* e)
{
    return (e) && (e->type() == g_workDomainChangeEventType);
}
//判断指定的事件是否是当前事件。
bool WRWorkDomainChangeEvent::identify(const QEvent& e)
{
    return e.type() == g_workDomainChangeEventType;
}


//初始化工作域改变事件。
WRWorkDomainChangeEvent::WRWorkDomainChangeEvent(WRWorkDomain* target, WRWorkDomain::Status status, WRWorkSession* session)
    : QEvent((QEvent::Type)g_workDomainChangeEventType)
{
    m_index = -1;
    m_target = target;
    m_status = status;
    m_session = session;
    if (m_session)
        m_session->addRef();
    else
        m_target->addRef();
}
//初始化工作域改变事件。
WRWorkDomainChangeEvent::WRWorkDomainChangeEvent(int index, WRWorkDomain* target, WRWorkDomain::Status status, WRWorkSession* session)
    : QEvent((QEvent::Type)g_workDomainChangeEventType)
{
    m_index = index;
    m_target = target;
    m_status = status;
    m_session = session;
    if (m_session)
        m_session->addRef();
    else
        m_target->addRef();
}
//释放当前对象所占用的相关资源。
WRWorkDomainChangeEvent::~WRWorkDomainChangeEvent(void)
{
    if (m_session)
        m_session->release();
    else
        m_target->release();
}
